package com.travelranking.service;

import java.util.List;

import org.springframework.transaction.annotation.Transactional;

import com.travelranking.converter.CityConverter;
import com.travelranking.converter.CountryConverter;
import com.travelranking.dao.RankingDAO;
import com.travelranking.pojo.City;
import com.travelranking.pojo.Country;

@Transactional
public class CityServiceImpl implements CityService {
	private RankingDAO dao; 
	
	
	@Override
	public void add(City city) {
		dao.saveCity(CityConverter.toEntity(city));
	}

	@Override
	public List<City> list() {
		return CityConverter.toPojoList( dao.listCity() );
	}
	
	@Override
	public List<City> listByCountry(Country country) {

		List<City> result = CityConverter.toPojoList( this.dao.listCityByCountry(CountryConverter.toEntity(country)) );
		
		return result;
	}

	public RankingDAO getDao() {
		return dao;
	}
	public void setDao(RankingDAO dao) {
		this.dao = dao;
	}

	
}
